/*
 * Copyright (c) Honor Device Co., Ltd. 2024-2024. All rights reserved.
 */

package com.wangfugui.mybatisplus.common;

/**
 * 异常枚举
 *
 * @since 2024-05-07
 */
public enum CommonErrorCode implements ErrorMessage {

    /**
     * 正确执行后的返回
     */
    SUCCESS(0, "SUCCESS"),

    // 通信协议错误
    /**
     * 404 Web 服务器找不到您所请求的文件或脚本。请检查URL 以确保路径正确。
     */
    NOT_FOUND(404, "could not find this resource"),

    /**
     * 403 无权限访问。
     */
    METHOD_NOT_AUTHC403(403, "has no access"),

    /**
     * 405 对于请求所标识的资源，不允许使用请求行中所指定的方法。请确保为所请求的资源设置了正确的 MIME 类型。
     */
    METHOD_NOT_ALLOWED(405, "method not allowed"),
    /**
     * 405 重新登录
     */
    METHOD_LOGIN_FIAL(400, "please login again"),

    /**
     * 415 Unsupported Media Type
     */
    UNSUPPORTED_MEDIA_TYPE(415, "unsupported media type"),

    /**
     * 系统异常 500 服务器的内部错误
     */
    SYSTEM_ERROR(500, "service exception"),
    /**
     * 服务异常
     */
    EXCEPTION_500(500, "service exception"),
    /**
     * 系统限流
     */
    TRAFFIC_LIMITING(429, "Network congestion, please try again later"),

    /**
     * 服务调用异常
     */
    API_GATEWAY_ERROR(9999, "The network is busy, please try again later"),

    /**
     * 参数错误
     */
    PARAM_ERROR(100, "Parameter error"),

    /**
     * 数据不存在
     */
    DATA_ERROR(100, "Data does not exist or has been deleted"),

    /**
     * 业务异常
     */
    BUSINESS_ERROR(100, "business exception"),

    /**
     * 获取csrfToken异常
     */
    CSRF_TOKEN_ERROR(100, "get csrfToken error"),

    /**
     * 非法请求
     */
    ILLEGAL_REQUEST(301, "Illegal request"),

    /**
     * 非法请求
     */
    FLOWNO_NOTEXIST(302, "Electronic flow number does not exist"),

    /**
     * rpc调用异常
     */
    RPC_ERROR(510, "There's something wrong with the network！"),
    /**
     * app信息不存在
     */
    APPINFO_NOTEXIST_ERROR(10406, "Watch app information does not exist"),
    /**
     * 类别不存在
     */
    CATEGORY_CATEGORYDESC_ERROR(10408, "Watch category or categoryDesc does not exist"),
    /**
     * 已经相关联
     */
    WATCH_IS_ASSOCIATED_ERROR(10407, "Watch is associated with the category"),
    /**
     * 已经包含子类别
     */
    WATCH_HAS_SUBCATEGORY_ERROR(10409, "Watch category contains subcategory");

    private Integer code;

    private String message;

    CommonErrorCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public Integer getCode() {
        return code;
    }
}
